{{- if .Values.collector.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: {{ template "jaeger.collector.name" . }}
  labels:
    {{- include "jaeger.labels" . | nindent 4 }}
    app.kubernetes.io/component: collector
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: {{ template "jaeger.collector.name" . }}
  minReplicas: {{ .Values.collector.autoscaling.minReplicas }}
  maxReplicas: {{ .Values.collector.autoscaling.maxReplicas }}
  metrics:
  {{- if .Values.collector.autoscaling.targetMemoryUtilizationPercentage }}
    - type: Resource
      resource:
        name: memory
        targetAverageUtilization: {{ .Values.collector.autoscaling.targetMemoryUtilizationPercentage }}
  {{- end }}
    - type: Resource
      resource:
        name: cpu
        targetAverageUtilization: {{ .Values.collector.autoscaling.targetCPUUtilizationPercentage | default 80 }}
{{- end }}
